$(function(){
	//判断默认选中的按钮，并设置默认手续费
	if($('input[name="corpPayBankCode"]').length>0&&$('input[name="corpPayBankCode"]').is(':checked')){
		setViewFee($("#corpBankPound"),$("#orderFeeAmt"));	
	}else if($('input[name="perBankPound"]').length>0&&$('input[name="perBankPound"]').is(':checked')){
		setViewFee($("#perBankPound"),$("#orderFeeAmt"));	
	}else if($('input[name="yesAvalPay"]').length>0&&$('input[name="yesAvalPay"]').is(':checked')){
		setViewFee($("#acctPound"),$("#orderFeeAmt"));	
	}
	
	$('input[name="payChannel"]').click(function(){
		if($(this).val()=="01"){
			$("#corpBankList").hide();
			$("#personalBankList").show();
			$('input[name="corpPayBankCode"]').removeAttr("checked");
			$("#i_b_c_0").attr("checked","checked");
			
			//动态修改手续费
			setViewFee($("#perBankPound"),$("#orderFeeAmt"));
			
		}else{
			$("#corpBankList").show();
			$("#personalBankList").hide();
			$('input[name="personalPayBankCode"]').removeAttr("checked");
			$("#e_b_c_0").attr("checked","checked");
			
			setViewFee($("#corpBankPound"),$("#orderFeeAmt"));
			
		}
	});
	
	
	$("#allPersonBanksDialog").dialog({
		autoOpen: false,
		modal: true,
		resizable: false,
		title: '选择银行',
		width:850,
		height:350,
		close:function(){
			payInMoneyPwdCtl("1");
		}
	});
	
	$("#allCorpBanksDialog").dialog({
		autoOpen: false,
		modal: true,
		resizable: false,
		title: '选择银行',
		width:775,
		height:350,
		close:function(){
			payInMoneyPwdCtl("1");
		}
	});
});

var onLineBankShow = function(){
	var userType = $("#defalutPayUserType").val();
	if(('01' == userType) && pbankNum>0){
		$("#personalBank").attr("checked","checked");
		$("#i_b_c_0").attr("checked","checked");
		$("#corpBankList").hide();
		$("#personalBankList").show();
	}else if(('02' == userType )&& ebankNum>0){
		$("#corpBank").attr("checked","checked");
		$("#e_b_c_0").attr("checked","checked");
		$("#corpBankList").show();
		$("#personalBankList").hide();
	}
};

var bankSel = function(bankImgId,img){
	$(img).parent().parent().parent().find("img").removeClass("cur");
	$(img).prop("class","cur");
	$("#"+bankImgId).attr("checked","checked");
	if(bankImgId){
		if(bankImgId.substring(0,1)=="e"){
			$("#corpBank").attr("checked","checked");
		}
		if(bankImgId.substring(0,1)=="i"){
			$("#personalBank").attr("checked","checked");
		}
	}
};

var showAllBanks = function(type){
	payInMoneyPwdCtl("0");
	if(type=="01"){
		$("#allPersonBanksDialog").dialog("open");
		$("#a_i_b_c_0").attr("checked","checked");
	}else if(type=="51"){
		$("#allCorpBanksDialog").dialog("open");
		$("#a_e_b_c_0").attr("checked","checked");
	}
};
//入金时，当弹出更多银行时，密码控件会遮挡
var payInMoneyPwdCtl = function(flag){
	var payInMoneyPasswordDiv = $("#payInMoneyPasswordDiv");
	if(payInMoneyPasswordDiv){
		if(flag=="0"){
			payInMoneyPasswordDiv.hide();
		}else{
			payInMoneyPasswordDiv.show();
		}
	}
};

var bankPaySubmit = function(type,formId){
	if(type=="01"){
		if(!($('input[name="personalPayBankCode"]:checked').val())){
			alert("请选择银行");
			return false;
		}
	}else if(type=="51"){
		if(!($('input[name="corpPayBankCode"]:checked').val())){
			alert("请选择银行");
			return false;
		}
	}
	payInMoneyPwdCtl("1");
	$("#"+formId).submit();
};